package com.tianpengtech.front.web.feedback;

import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.model.feedback.FeedBack;
import com.tianpengtech.common.validator.Validator;
import com.tianpengtech.common.validator.rules.string.StringLengthBetween;
import com.tianpengtech.common.validator.rules.string.StringMustBeMobile;

/**
 * Created by ggd on 2017/5/28 0028.
 */
public class FeedBackService {
    public static final FeedBackService me = new FeedBackService();


    /**
     * 保存
     * @param feedBack
     * @throws ValidateException 
     */
    public boolean save(FeedBack feedBack) throws ValidateException{
    	
    	Validator validator = new Validator();
    	validator.addRule(new StringMustBeMobile(feedBack.getStr(FeedBack.CONTACT), "请填入联系人合法的手机号码"));
    	validator.addRule(new StringLengthBetween(feedBack.getStr(FeedBack.CONTENT), "意见反馈内容只能是1-500个字符",1,500));
    	validator.excute();
        return feedBack.save();
    }


}
